


public class Shape{

	public int current[][];
	public int x_coord;
	public int y_coord;

	private static int nb_shapes = 7;

	public Shape(int x_coord, int y_coord)
	{
		int num = (int)(Math.random()*nb_shapes) ;
		

		switch(num)
		{
			case 0:
				current = new int[4][4];
				int t0[] = {1,1,1,1};
				System.arraycopy(t0,0,current[1],0,4);
				
				break;
		
			case 1:
				current = new int[3][3];
				int t1[] = {0,2,0};
				int t2[] = {2,2,2};
				System.arraycopy(t1,0,current[0],0,3);
				System.arraycopy(t2,0,current[1],0,3);
				
				break;
		
			case 2:
				current = new int[2][2];
				int t3[] ={3,3};
				System.arraycopy(t3,0,current[0],0,2);
				System.arraycopy(t3,0,current[1],0,2);
			
				break;
		
			case 3:
				current = new int[3][3];
				int t4[] = {4,4,0};
				int t5[] = {0,4,4};
				System.arraycopy(t4,0,current[0],0,3);
				System.arraycopy(t5,0,current[1],0,3);
				
				break;
		
			case 4:
				current = new int[3][3];
				int t6[] ={0,5,5};
				int t7[] ={5,5,0};
				System.arraycopy(t6,0,current[0],0,3);
				System.arraycopy(t7,0,current[1],0,3);
				

				break;
		
			case 5:
				current = new int[3][3];
				int t8[] ={6,0,0};
				int t9[] ={6,6,0};
				System.arraycopy(t8,0,current[0],0,3);
				System.arraycopy(t8,0,current[1],0,3);
				System.arraycopy(t9,0,current[2],0,3);
				
				break;
		
			case 6:
				current = new int[3][3];
				int t10[] ={0,0,7};
				int t11[] ={0,7,7};
				System.arraycopy(t10,0,current[0],0,3);
				System.arraycopy(t10,0,current[1],0,3);
				System.arraycopy(t11,0,current[2],0,3);
				
				break;
		
			default:
				System.out.println("Erreur dans le switch: valeur inatendue:"+num+" !");
		}

		this.x_coord = x_coord;
		this.y_coord = y_coord;

	}


	public void rotate()
	{
		int size = this.current.length;
		int newShape[][] = new int[size][size]; 
		
		for (int y = 0;  y < size; y++)
			for (int x = 0; x < size; x++)
				newShape[y][x] = this.current[-x + size -1][y];
	
		this.current = newShape;
	}

	public void moveDown()
	{
		this.y_coord +=1;
	}

	public void moveUp()
	{
		this.y_coord -= 1;
	}

	public void moveRight()
	{
		this.x_coord +=1;
	}

	public void moveLeft()
	{
		this.x_coord -=1;
	}
	

	public String toString()
	{
		String str = "";
		for (int lines[]: this.current)
		{
			for(int content: lines)
				str+=content+ " ";
			str+= "\n";
		}
		
		return str;
	}

	
	public int shapeSize()
	{
		return this.current.length;
	}


}

